function transect_magnetics(ctr,All)

%Load and plot grid data
R=region_data_all(ctr);
fname=['../../generate_profiles/data/data_',R.name,'.mat']; load(fname,'C','P');

subplot('position',[0.05 0.1 0.85 0.5]); hold on;

%plot magnetic profiles
for ct=1:length(P.T),
    ipl1=P.T(ct).BM(1).ipl; %index of the location of the B-M magnetic reversal on one side
    ipl2=P.T(ct).BM(2).ipl; %index of the location of the B-M magnetic reversal on the other side
    mag=P.T(ct).mag; %magnetic profile
    [~,m]=min(abs(P.T(ct).dist));
    mmag=mag(m); %value at center point, for marker
    plot(P.T(ct).dist,mag-mmag+250*ct,'k','linewidth',1);
    plot(0,250*ct,'ro','markersize',12,'linewidth',2); 
    
        %plot magnetic profile and B-M location on one side
        mag=P.T(ct).imag(ipl1);
        plot(P.T(ct).idist(ipl1),(mag-mmag)+250*ct,'r.','markersize',22);
        
        %plot magnetic profile and B-M location on the other side
        if ~isempty(P.T(ct).BM(2).mag)
        mag=P.T(ct).imag(ipl2);
        plot(P.T(ct).idist(ipl2),(mag-mmag)+250*ct,'r.','markersize',22);
        end
end;
axis tight; h4=axis;
for ct=1:length(P.T);
    text(h4(2),250*(ct-1),num2str(ct,2),'fontsize',15,'linewidth',1);
end;

%give a little space on the left
axis([h4(1)-diff(h4(1:2))*0.05 h4(2:4)]); h4=axis;

%region label
plot([0 0],h4(3:4),'k--','linewidth',1);
text(h4(1),h4(4)-0.05*diff(h4(3:4)),'magnetic anomaly','fontsize',18); 
axis off;

%make a vertical bar indicating units and scaling
dx=diff(h4(1:2));
dy=diff(h4(3:4));
x=[1 1]*h4(1)+0.001*dx;
y=[h4(4)-0.15*dy h4(4)-0.15*dy-200];
plot(x,y,'k','linewidth',1.5);
if dy>8*250;
    label=[0 200];
end;
if dy<=8*250 & dy>4*250;
    label=[0 100 200];
end;
if dy<=4*250;
    label=[0 50 100 150 200];
end;

%transect number labels
for ct=1:length(label);
    plot([x(1) x(1)+0.005*dx],y(2)*[1 1]+label(ct),'k','linewidth',1.5);
    text(x(1)+0.01*dx,y(2)+label(ct),[num2str(label(ct)),' nT'],'linewidth',1.5,'fontsize',12);
end;

%make x-axis
subplot('position',[0.05 0.098 0.85 0.001]); 
axis([h4(1:2) 0 1]);
font(gca,15);
h=xlabel('distance (km)'); font(h,15);




